package controller;

import java.util.ArrayList;

import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

// Plain old Java Object it does not extend as class or implements 
// an interface

// The class registers its methods for the HTTP GET request using the @GET annotation. 
// Using the @Produces annotation, it defines that it can deliver several MIME types,
// text, XML and HTML. 

// The browser requests per default the HTML MIME type.

//Sets the path to base URL + /hello
@Path("/hello")
public class Hello {

//  // This method is called if TEXT_PLAIN is request
//  @GET
//  @Produces(MediaType.TEXT_PLAIN)
//  public String sayPlainTextHello() {
//    return "Hello Jersey";
//  }
//
//  // This method is called if XML is request
//  @GET
//  @Produces(MediaType.TEXT_XML)
//  public String sayXMLHello() {
//    return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
//  }

  // This method is called if HTML is request
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  //@Consumes("application/x-www-form-urlencoded")
  public ArrayList<Pessoa> sayHtmlHello(@QueryParam("step") int step) {
	  
	  System.out.println(step);
	  
	  ArrayList<Pessoa> arr = new ArrayList<Pessoa>();
	  
	  Pessoa moises = new Pessoa();
	  moises.setFirstName("Moises");
	  moises.setLastName("Santana");
	  
	  Pessoa didi = new Pessoa();
	  didi.setFirstName("Didi");
	  didi.setLastName("Bem");
	  	  
	  arr.add(moises);
	  arr.add(didi);
	  
	  return arr;
  }

} 